﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sealight.Core.Common;

namespace Sealight.Core.Domain
{
    public class OrderEntity:BaseEntity
    {
        public virtual Guid OrderID { get; set; }
        public virtual string Name { get; set; }
        public virtual string Description { get; set; }
        public virtual DateTime CreatedDate { get; set; }
        public virtual DateTime ModifiedDate { get; set; }
        /// <summary>
        /// Gets or sets the order total
        /// </summary>
        public virtual decimal OrderTotal { get; set; }

        /// <summary>
        /// Gets or sets the order discount
        /// </summary>
        public virtual decimal OrderDiscount { get; set; }

        /// <summary>
        /// Gets or sets an order status identifer
        /// </summary>
        public virtual OrderStatus OrderStatus { get; set; }

        public virtual UserEntity User { get; set; }
        public virtual PaymentMethodEntity PaymentMethod { get; set; }
        public virtual PaymentStatus PaymentStatus { get; set; }

        public virtual IList<OrderProductVariantEntity> OrderProducts { get; set; }

        public virtual Sealight.Core.DataAdapter.order ToDataAdapter()
        {
            return new DataAdapter.order
            {id = this.OrderID, name=this.Name, created_date=this.CreatedDate, 
                description=this.Description, modified_date=this.ModifiedDate, order_discount=this.OrderDiscount,
            order_status = this.OrderStatus, order_total=this.OrderTotal, 
            payment_method=this.PaymentMethod.ToDataAdapter(), user=this.User.ToDataAdapter(), payment_status=this.PaymentStatus=this.PaymentStatus,
            order_products = this.OrderProducts!=null?(from c in this.OrderProducts select c.ToDataAdapter()).ToList():null
            };
        }
    }
}
